package com.yh.controller;

import com.yh.util.BaseAction;
import com.yh.util.CpachaUtil;
import com.yh.util.DateUtil;
import lombok.Getter;
import lombok.Setter;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;

public class YzmAction extends BaseAction {
    @Getter
    @Setter
    private String vl;
    static String  generatorVCode;

    public String yzm() throws Exception {
        CpachaUtil cpachaUtil = new CpachaUtil();
         generatorVCode = cpachaUtil.generatorVCode();//获取随机验证码
        System.out.println("验证码:"+generatorVCode+",time:"+"时间"+ DateUtil.getCurrTime());//request.getParameter("t")
        getSession().setAttribute("loginCpacha", generatorVCode);
        //生成图片  参数1：要画验证码  参数2：是否画干扰线
        BufferedImage image = cpachaUtil.generatorRotateVCodeImage(generatorVCode, true);
        //将验证码图片输出到页面上
        ImageIO.write(image, "gif", getResponse().getOutputStream());
        return null;
    }


}
